package com.example.demo.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*@ControllerAdvice注解会使controller中方法的异常交给此处进行处理。*/
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public String userNull(Exception e) {
        e.printStackTrace();
        return "MyExceptionHandler" + e.getMessage();
    }
}